package listen;

import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Date;

import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpServletRequest;

public class DayVisitListener implements ServletRequestListener {

	@Override
	public void requestDestroyed(ServletRequestEvent arg0) {
		// TODO 自动生成的方法存根

	}

	@Override
	public void requestInitialized(ServletRequestEvent arg0) {
		try {
			FileWriter file = new FileWriter("K:\\javaeeLog\\requestLog.txt", true);
			PrintWriter out = new PrintWriter(file);
			HttpServletRequest request=(HttpServletRequest)arg0.getServletRequest();
			out.println(new Date() + " " + request.getRemoteAddr() + " " + request.getRequestURI());
			out.close();
		}
		catch (Exception e) {
			System.out.println(e);
		}
	}
}
